﻿@{
    ViewBag.Title = "ReportIndex";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<script>
    $(function () {
        $("#txtSchoolId").bindSelect({
            url: "/Gas/Apply/GetEnableSchoolSelectJson",
        });
        $("#txtClass").bindSelect({
            url: "/SystemManage/ItemsData/GetSelectJson",
            param: { enCode: "Class" }
        });
        gridList();
        $("#gridList").jqGrid('setLabel', 'rn', '序号', { 'text-align': 'center', 'vertical-align': 'middle','width':'50' });
    })
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            url: "/Gas/Apply/GetReportDataJson",
            height: $(window).height() - 120,
            colModel: [
                {
                    label: '学校', name: 'SchoolId', width: 300, align: 'center',
                    formatter: function (cellvalue) {
                        return top.clients.schoolItems[cellvalue] == undefined ? "" : top.clients.schoolItems[cellvalue].schoolName
                    }
                },
                {
                    label: '年级', name: 'ClassValue', width: 100, align: 'center',
                    formatter: function (cellvalue) {
                        return top.clients.dataItems["Class"][cellvalue] == undefined ? "" : top.clients.dataItems["Class"][cellvalue]
                    }
                },
                { label: "年级学位总数", name: "ClassFreeTotalAmount", width: 150, align: 'center' },
                { label: '年级学位剩余数', name: 'ClassFreeAmount', width: 150, align: 'center' },
                { label: '未提交', name: 'NoSumbitAmount', width: 120, align: 'center' },
                { label: '提交待初审', name: 'SumbitAmount', width: 120, align: 'center' },
                { label: '初审未通过', name: 'FirstNoPassAmount', width: 120, align: 'center' },
                { label: '预录取', name: 'PreAdmitAmount', width: 120, align: 'center' },
                { label: '录取', name: 'AdmitAmount', width: 120, align: 'center' },
                { label: '未录取', name: 'NoAdmitAmount', width: 120, align: 'center' },
                { label: '合计', name: 'TotalAmount', width: 120, align: 'center' },
            ],
            pager: "#gridPager",
            sortname: 'SchoolId asc',
            viewrecords: true,
            footerrow: true,
            loadComplete: function (xhr) {
                var rows = $("#gridList").jqGrid("getRowData");
                var total_ClassFreeTotalAmount = 0;
                var total_ClassFreeAmount = 0;
                var total_NoSumbitAmount = 0;
                var total_SumbitAmount = 0;
                var total_FirstNoPassAmount = 0;
                var total_PreAdmitAmount = 0;
                var total_AdmitAmount = 0;
                var total_NoAdmitAmount = 0;
                var total_TotalAmount = 0;
                for (var i = 0, l = xhr.rows.length; i < l; i++) {
                    total_ClassFreeTotalAmount += parseInt(xhr.rows[i].ClassFreeTotalAmount);
                    total_ClassFreeAmount += parseInt(xhr.rows[i].ClassFreeAmount);
                    total_NoSumbitAmount += parseInt(xhr.rows[i].NoSumbitAmount);
                    total_SumbitAmount += parseInt(xhr.rows[i].SumbitAmount);
                    total_FirstNoPassAmount += parseInt(xhr.rows[i].FirstNoPassAmount);
                    total_PreAdmitAmount += parseInt(xhr.rows[i].PreAdmitAmount);
                    total_AdmitAmount += parseInt(xhr.rows[i].AdmitAmount);
                    total_NoAdmitAmount += parseInt(xhr.rows[i].NoAdmitAmount);
                    total_TotalAmount += parseInt(xhr.rows[i].TotalAmount);
                }
                $("#gridList").jqGrid("footerData", "set", {
                    rn: "<font color='red'>合计</font>",
                    ClassFreeTotalAmount: "<font color='red'> " + total_ClassFreeTotalAmount + "</font>",
                    ClassFreeAmount: "<font color='red'> " + total_ClassFreeAmount + "</font>",
                    NoSumbitAmount: "<font color='red'> " + total_NoSumbitAmount + "</font>",
                    SumbitAmount: "<font color='red'> " + total_SumbitAmount + "</font>",
                    FirstNoPassAmount: "<font color='red'> " + total_FirstNoPassAmount + "</font>",
                    PreAdmitAmount: "<font color='red'> " + total_PreAdmitAmount + "</font>",
                    AdmitAmount: "<font color='red'> " + total_AdmitAmount + "</font>",
                    NoAdmitAmount: "<font color='red'> " + total_NoAdmitAmount + "</font>",
                    TotalAmount: "<font color='red'> " + total_TotalAmount + "</font>",
                });
            }
        });
        $("#btn_search").click(function () {
            $gridList.jqGrid('setGridParam', {
                postData: { schoolId: $("#txtSchoolId").val(), classValue: $("#txtClass").val() },
            }).trigger('reloadGrid');
        });
    }
    function btn_DownloadReportInfo() {
        window.location.href = "/Gas/Apply/ExportReportInfo?schoolId=" + $("#txtSchoolId").val() + "&classValue=" + $("#txtClass").val();
    }
</script>
<div class="topPanel">
    <div class="toolbar">
        <div class="btn-group">
            <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
        </div>
        <div class="btn-group">
            <a href="#" id="NF-DownloadReportInfo" class="btn btn-primary" onclick="btn_DownloadReportInfo()"><span class="glyphicon glyphicon-download">导出统计报表</span></a>
        </div>
    </div>
    <div class="search">
        <table>
            <tr>
                <td>
                    <div class="input-group">
                        <select id="txtSchoolId" class="form-control" style="width:180px"></select>
                        <select id="txtClass" class="form-control" style="width:120px">
                            <option value="">请选择年级</option>
                        </select>
                        <span class="input-group-btn">
                            <button id="btn_search" type="button" class="btn  btn-primary"><i class="fa fa-search"></i></button>
                        </span>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</div>
<div class="gridPanel">
    <table id="gridList"></table>
    <div id="gridPager"></div>
</div>
<div id="my-modal" class="modal fade" data-placement="center" tabindex="-1">
    <div class="modal-dialog">
        <div class="modal-content">
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>